package com.woniu.nacosconfig.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/conf")
@RefreshScope //开启自动刷新配置
public class ConfigController {
    @Value("${server.port}")
    private int port;

    @GetMapping("/getPort")
    public String getPort() {
        return "当前服务端口：" + port;
    }

    @Value("${my.msg}")
    private String msg;

    @GetMapping("/getMsg")
    public String getMsg() {
        return "当前服务信息：" + msg;
    }
}
